﻿using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Scheduler.Model
{
    /// <summary>
    /// 路由菜单表
    /// </summary>
    //[Table("permission")]
    [Comment("路由菜单表")]
    public class Permission : BaseEntity
    {
        /// <summary>
        /// 菜单执行Action名
        /// </summary>
        [Comment("菜单执行Action名")]
        [StringLength(50)]
        [Required]
        public string? Code { get; set; }
        /// <summary>
        /// 菜单显示名（如用户页、编辑(按钮)、删除(按钮)）
        /// </summary>
        [Comment("菜单显示名（如用户页、编辑(按钮)、删除(按钮)）")]
        [StringLength(50)]
        [Required]
        public string? Name { get; set; }
        /// <summary>
        /// 是否是按钮
        /// </summary>
        [Comment("是否是按钮")]
        [Required]
        public bool IsButton { get; set; } = false;
        /// <summary>
        /// 是否是隐藏菜单
        /// </summary>
        [Comment("是否是隐藏菜单")]
        [Required]
        public bool? IsHide { get; set; } = false;
        /// <summary>
        /// 是否keepAlive
        /// </summary>
        [Comment("是否keepAlive")]
        [Required]
        public bool? IskeepAlive { get; set; } = false;
        /// <summary>
        /// 按钮事件
        /// </summary>
        [Comment("按钮事件")]
        [StringLength(100)]
        public string? Func { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        [Comment("排序")]
        [Required]
        public int OrderSort { get; set; }
        /// <summary>
        /// 菜单图标
        /// </summary>
        [Comment("菜单图标")]
        [StringLength(100)]
        [Required]
        public string? Icon { get; set; }
        /// <summary>
        /// 菜单描述    
        /// </summary>
        [Comment("菜单描述")]
        [StringLength(100)]
        public string? Description { get; set; }
        /// <summary>
        /// 激活状态
        /// </summary>
        [Comment("激活状态")]
        public bool Enabled { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [NotMapped]
        public List<string?> PnameArr { get; set; } = new List<string?>();
        /// <summary>
        /// 
        /// </summary>
        [NotMapped]
        public List<string?> PCodeArr { get; set; } = new List<string?>();
        /// <summary>
        /// 菜单名称
        /// </summary>
        [NotMapped]
        public string? MName { get; set; }
        /// <summary>
        /// 是否有子级
        /// </summary>
        [NotMapped]
        public bool hasChildren { get; set; } = true;
        /// <summary>
        /// 接口API地址信息表
        /// </summary>
        [NotMapped]
        public Modules? Module { get; set; }
        /// <summary>
        /// 菜单Id
        /// </summary>
        [NotMapped]
        public int? Key { get; set; }
        /// <summary>
        /// 父级菜单Id
        /// </summary>
        [NotMapped]
        public int? ParentKey { get; set; } = 0;

    }
}
